﻿local L = AOSS_LOCAL_STRINGS

function AOSSControlsFontStrings_OnLoad(frame)	
	frame.name = L.CONTROLS_FONTSTRINGS_NAME
	frame.parent = CONTROL_PARENT
	AOSS_AddCategory(frame)
	
	ShowExampleFontString("GameFontNormal");
	
	-- Set the text of the example font string (show escape sequences)
	ExampleFontString:SetText([[Sets text |c66006600color|r. Text following this escape sequence will be drawn in this color. 
Each pair of digits represents a color value (plus the alpha value, however the alpha value is currently ignored and should always be FF) as a hexadecimal number.

Textures: |TInterface\BUTTONS\UI-GroupLoot-Dice-Up:32|t]]);
	
end

function FontStringsDropDown_Initialize(level)   	
	local infos = { 
		"ChatFontNormal",
		"CombatLogFont",
		"CombatTextFont",
		"DialogButtonHighlightText",
		"DialogButtonNormalText",
		"ErrorFont",
		"GameFontNormal", 				
		"GameFontHighlight",
		"GameFontDisable",										
		"GameFontHighlightSmallOutline",		
		"GameTooltipText",		
		"GameTooltipHeaderText",
		"InvoiceTextFontNormal",		
		"ItemTextFontNormal",
		"MailTextFontNormal",
		"NumberFontNormal",				
		"QuestTitleFont",
		"QuestFont",		
		"QuestFontHighlight",
		"SubSpellFont",
		"SubZoneTextFont",
		"TextStatusBarText",		
		"WorldMapTextFont",
		"ZoneTextFont",
		};		
	UIDropDownMenu_AddButtons(infos, FontStringsDropDownItem_Click);		
end

function FontStringsDropDownItem_Click(self)	   
   local value = self:GetID();
   local dropdown = FontstringsDropDown;
   UIDropDownMenu_SetSelectedID(dropdown, value, 1);
         
   ShowExampleFontString(self:GetText());
end

local lastFontString;

function ShowExampleFontString(name)   
   if (lastFontString) then
		lastFontString:Hide();
   end   

   local fontString = getglobal(name.."Example");   
  
   if (fontString == nil) then					   
	   fontString = AOSSControlsFontStrings:CreateFontString(name.."Example", "OVERLAY", name);	   
	   fontString:SetText("Sample text");
	   fontString:SetPoint("CENTER", FontstringsDropDown, "RIGHT", 90, 2);	   
   end
   
   fontString:Show();
   lastFontString = fontString;	
end